package phase1.part3;

/**
 * 
 * 
 * @author John Girata
 * @version Nov 1, 2012
 */
public class Transition {
	private State end;
	private Matcher pattern;

	public Transition(State end, Matcher pattern) {
		this.end = end;
		this.pattern = pattern;
	}

	public State getEnd() {
		return end;
	}

	public void setEnd(State end) {
		this.end = end;
	}

	public Matcher getPattern() {
		return pattern;
	}

	public void setPattern(Matcher pattern) {
		this.pattern = pattern;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((end == null) ? 0 : end.hashCode());
		result = prime * result + ((pattern == null) ? 0 : pattern.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof Transition))
			return false;
		Transition other = (Transition) obj;
		if (end == null) {
			if (other.end != null)
				return false;
		} else if (!end.equals(other.end))
			return false;
		if (pattern == null) {
			if (other.pattern != null)
				return false;
		} else if (!pattern.equals(other.pattern))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "Transition [end=" + end + ", pattern=" + pattern + "]";
	}
}
